<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../../../../">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>pyokx.okx_market_maker.position_management_service.model.Account &mdash; AntBot 0.0.1 documentation</title>
      <link rel="stylesheet" type="text/css" href="../../../../../_static/pygments.css?v=80d5e7a1" />
      <link rel="stylesheet" type="text/css" href="../../../../../_static/css/theme.css?v=19f00094" />
      <link rel="stylesheet" type="text/css" href="../../../../../_static/graphviz.css?v=eafc0fe6" />

  
  <!--[if lt IE 9]>
    <script src="../../../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="../../../../../_static/jquery.js?v=5d32c60e"></script>
        <script src="../../../../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
        <script src="../../../../../_static/documentation_options.js?v=d45e8c67"></script>
        <script src="../../../../../_static/doctools.js?v=888ff710"></script>
        <script src="../../../../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="../../../../../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../../search.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../../../../../index.html" class="icon icon-home">
            AntBot
          </a>
              <div class="version">
                0.0.1
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../../autodocumentation_python.html">autodocumentation_python</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../firebase_tools.BaseClasses.html">firebase_tools.BaseClasses</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../firebase_tools.FirestoreClient.html">firebase_tools.FirestoreClient</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../firebase_tools.authenticate.html">firebase_tools.authenticate</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../h2o_dashboard.dashboard.html">h2o_dashboard.dashboard</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../h2o_dashboard.pages.documentation_page.html">h2o_dashboard.pages.documentation_page</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../h2o_dashboard.pages.okx_dashbaord_page.okx_antbot_okx_premium_indicator_handler.html">h2o_dashboard.pages.okx_dashbaord_page.okx_antbot_okx_premium_indicator_handler</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../h2o_dashboard.pages.okx_dashbaord_page.okx_dashboard_page.html">h2o_dashboard.pages.okx_dashbaord_page.okx_dashboard_page</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../h2o_dashboard.pages.okx_streams.html">h2o_dashboard.pages.okx_streams</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../h2o_dashboard.pages.overview_page.html">h2o_dashboard.pages.overview_page</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../h2o_dashboard.util.html">h2o_dashboard.util</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../h2o_dashboard.wave_auth.html">h2o_dashboard.wave_auth</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.Futures_Exchange_Client.html">pyokx.Futures_Exchange_Client</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.InstrumentSearcher.html">pyokx.InstrumentSearcher</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.data_structures.html">pyokx.data_structures</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.Account.html">pyokx.low_rest_api.Account</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.BlockTrading.html">pyokx.low_rest_api.BlockTrading</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.Convert.html">pyokx.low_rest_api.Convert</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.CopyTrading.html">pyokx.low_rest_api.CopyTrading</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.Earning.html">pyokx.low_rest_api.Earning</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.FDBroker.html">pyokx.low_rest_api.FDBroker</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.Funding.html">pyokx.low_rest_api.Funding</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.Grid.html">pyokx.low_rest_api.Grid</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.MarketData.html">pyokx.low_rest_api.MarketData</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.NDBroker.html">pyokx.low_rest_api.NDBroker</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.PublicData.html">pyokx.low_rest_api.PublicData</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.SpreadTrading.html">pyokx.low_rest_api.SpreadTrading</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.Status.html">pyokx.low_rest_api.Status</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.SubAccount.html">pyokx.low_rest_api.SubAccount</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.Trade.html">pyokx.low_rest_api.Trade</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.TradingData.html">pyokx.low_rest_api.TradingData</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.client.html">pyokx.low_rest_api.client</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.consts.html">pyokx.low_rest_api.consts</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.exceptions.html">pyokx.low_rest_api.exceptions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.low_rest_api.utils.html">pyokx.low_rest_api.utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.market_data_service.WssMarketDataService.html">pyokx.okx_market_maker.market_data_service.WssMarketDataService</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.market_data_service.model.Instrument.html">pyokx.okx_market_maker.market_data_service.model.Instrument</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.market_data_service.model.MarkPx.html">pyokx.okx_market_maker.market_data_service.model.MarkPx</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.market_data_service.model.OrderBook.html">pyokx.okx_market_maker.market_data_service.model.OrderBook</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.market_data_service.model.Tickers.html">pyokx.okx_market_maker.market_data_service.model.Tickers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.order_management_service.WssOrderManagementService.html">pyokx.okx_market_maker.order_management_service.WssOrderManagementService</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.order_management_service.model.Order.html">pyokx.okx_market_maker.order_management_service.model.Order</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.order_management_service.model.OrderRequest.html">pyokx.okx_market_maker.order_management_service.model.OrderRequest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.position_management_service.WssPositionManagementService.html">pyokx.okx_market_maker.position_management_service.WssPositionManagementService</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.position_management_service.model.Account.html">pyokx.okx_market_maker.position_management_service.model.Account</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.position_management_service.model.BalanceAndPosition.html">pyokx.okx_market_maker.position_management_service.model.BalanceAndPosition</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.position_management_service.model.Positions.html">pyokx.okx_market_maker.position_management_service.model.Positions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.run_sample_market_maker.html">pyokx.okx_market_maker.run_sample_market_maker</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.settings.html">pyokx.okx_market_maker.settings</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.strategy.BaseStrategy.html">pyokx.okx_market_maker.strategy.BaseStrategy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.strategy.SampleMM.html">pyokx.okx_market_maker.strategy.SampleMM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.strategy.model.StrategyMeasurement.html">pyokx.okx_market_maker.strategy.model.StrategyMeasurement</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.strategy.model.StrategyOrder.html">pyokx.okx_market_maker.strategy.model.StrategyOrder</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.strategy.params.ParamsLoader.html">pyokx.okx_market_maker.strategy.params.ParamsLoader</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.strategy.risk.RiskCalculator.html">pyokx.okx_market_maker.strategy.risk.RiskCalculator</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.strategy.risk.RiskSnapshot.html">pyokx.okx_market_maker.strategy.risk.RiskSnapshot</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.tests.test_strategy.html">pyokx.okx_market_maker.tests.test_strategy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.utils.InstrumentUtil.html">pyokx.okx_market_maker.utils.InstrumentUtil</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.utils.OkxEnum.html">pyokx.okx_market_maker.utils.OkxEnum</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.utils.TdModeUtil.html">pyokx.okx_market_maker.utils.TdModeUtil</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.okx_market_maker.utils.WsOrderUtil.html">pyokx.okx_market_maker.utils.WsOrderUtil</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.redis_structured_reports.html">pyokx.redis_structured_reports</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.redis_structured_streams.html">pyokx.redis_structured_streams</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.rest_handling.html">pyokx.rest_handling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.rest_messages_service.html">pyokx.rest_messages_service</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.strategy_handling.html">pyokx.strategy_handling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.AccountTest.html">pyokx.test.AccountTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.BlockTradingTest.html">pyokx.test.BlockTradingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.BrokerTest.html">pyokx.test.BrokerTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.ConvertTest.html">pyokx.test.ConvertTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.CopyTradingTest.html">pyokx.test.CopyTradingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.EarningTest.html">pyokx.test.EarningTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.FundingTest.html">pyokx.test.FundingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.GridTest.html">pyokx.test.GridTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.MarketTest.html">pyokx.test.MarketTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.PublicDataTest.html">pyokx.test.PublicDataTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.SpreadTest.html">pyokx.test.SpreadTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.StackingTest.html">pyokx.test.StackingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.SubAccountTest.html">pyokx.test.SubAccountTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.TradeTest.html">pyokx.test.TradeTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.TradingDataTest.html">pyokx.test.TradingDataTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.WsPrivateAsyncTest.html">pyokx.test.WsPrivateAsyncTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.test.WsPublicAsyncTest.html">pyokx.test.WsPublicAsyncTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.websocket_handling.html">pyokx.websocket_handling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.ws_clients.WebSocketFactory.html">pyokx.ws_clients.WebSocketFactory</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.ws_clients.WsPprivateAsync.html">pyokx.ws_clients.WsPprivateAsync</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.ws_clients.WsPublicAsync.html">pyokx.ws_clients.WsPublicAsync</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.ws_clients.WsUtils.html">pyokx.ws_clients.WsUtils</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pyokx.ws_data_structures.html">pyokx.ws_data_structures</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../redis_tools.config.html">redis_tools.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../redis_tools.consumers.html">redis_tools.consumers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../redis_tools.utils.html">redis_tools.utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../rest_app.html">rest_app</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../routers.api_keys.html">routers.api_keys</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../routers.login.html">routers.login</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../routers.okx.html">routers.okx</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../routers.okx_authentication.html">routers.okx_authentication</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../routers.signup.html">routers.signup</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../shared.command_execution.html">shared.command_execution</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../shared.config.html">shared.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../shared.configuration_parser.html">shared.configuration_parser</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../shared.data_processing_utils.html">shared.data_processing_utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../shared.file_directory_ops.html">shared.file_directory_ops</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../shared.logging.html">shared.logging</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../shared.string_dict_utils.html">shared.string_dict_utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../shared.tmp_shared.html">shared.tmp_shared</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../tradingview_tools.tradingview_widgets.html">tradingview_tools.tradingview_widgets</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../websocket_app.html">websocket_app</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../../../index.html">AntBot</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../../../../index.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../../../index.html">Module code</a></li>
      <li class="breadcrumb-item active">pyokx.okx_market_maker.position_management_service.model.Account</li>
      <li class="wy-breadcrumbs-aside">
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <h1>Source code for pyokx.okx_market_maker.position_management_service.model.Account</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">dataclass</span><span class="p">,</span> <span class="n">field</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Dict</span>

<span class="kn">from</span> <span class="nn">pydantic</span> <span class="kn">import</span> <span class="n">BaseModel</span>


<div class="viewcode-block" id="AccountDetail">
<a class="viewcode-back" href="../../../../../pyokx.okx_market_maker.position_management_service.model.Account.html#pyokx.okx_market_maker.position_management_service.model.Account.AccountDetail">[docs]</a>
<span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">AccountDetail</span><span class="p">:</span>
    <span class="n">avail_bal</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">avail_eq</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">ccy</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
    <span class="n">cash_bal</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">u_time</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">dis_eq</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">eq</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">eq_usd</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">frozen_bal</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">interest</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">iso_eq</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">liability</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">max_loan</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">notional_lever</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">ord_frozen</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">upl</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">upl_liability</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">cross_liability</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">iso_liability</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">coin_usd_price</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">strategy_eq</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">spot_in_usd_amt</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">iso_upl</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>

<div class="viewcode-block" id="AccountDetail.init_from_ws_json_message">
<a class="viewcode-back" href="../../../../../pyokx.okx_market_maker.position_management_service.model.Account.html#pyokx.okx_market_maker.position_management_service.model.Account.AccountDetail.init_from_ws_json_message">[docs]</a>
    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">init_from_ws_json_message</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">json_response</span><span class="p">):</span>
        <span class="n">account_detail</span> <span class="o">=</span> <span class="n">AccountDetail</span><span class="p">()</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">avail_bal</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;availBal&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;availBal&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">avail_eq</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;availEq&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;availEq&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">ccy</span> <span class="o">=</span> <span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;ccy&quot;</span><span class="p">]</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">cash_bal</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;cashBal&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;cashBal&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">u_time</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;uTime&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;uTime&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">eq</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;eq&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;eq&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">eq_usd</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;eqUsd&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;eqUsd&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">frozen_bal</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;frozenBal&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;frozenBal&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">interest</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;interest&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;interest&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">iso_eq</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;isoEq&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;isoEq&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">liability</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;liab&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;liab&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">max_loan</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;maxLoan&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;maxLoan&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">notional_lever</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;notionalLever&quot;</span><span class="p">])</span> \
            <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;notionalLever&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">ord_frozen</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;ordFrozen&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;ordFrozen&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">upl</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;upl&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;upl&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">upl_liability</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;uplLiab&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;uplLiad&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">cross_liability</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;crossLiab&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;crossLiab&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">iso_liability</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;isoLiab&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;isoLiab&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">coin_usd_price</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;coinUsdPrice&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;coinUsdPrice&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">strategy_eq</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;stgyEq&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;stgyEq&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">spot_in_usd_amt</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;spotInUseAmt&quot;</span><span class="p">])</span> \
            <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;spotInUseAmt&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account_detail</span><span class="o">.</span><span class="n">iso_upl</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;isoUpl&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">json_response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;isoUpl&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="k">return</span> <span class="n">account_detail</span></div>


<div class="viewcode-block" id="AccountDetail.to_dict">
<a class="viewcode-back" href="../../../../../pyokx.okx_market_maker.position_management_service.model.Account.html#pyokx.okx_market_maker.position_management_service.model.Account.AccountDetail.to_dict">[docs]</a>
    <span class="k">def</span> <span class="nf">to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="p">{</span>
            <span class="s2">&quot;avail_bal&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">avail_bal</span><span class="p">,</span>
            <span class="s2">&quot;avail_eq&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">avail_eq</span><span class="p">,</span>
            <span class="s2">&quot;ccy&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">ccy</span><span class="p">,</span>
            <span class="s2">&quot;cash_bal&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">cash_bal</span><span class="p">,</span>
            <span class="s2">&quot;u_time&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">u_time</span><span class="p">,</span>
            <span class="s2">&quot;dis_eq&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">dis_eq</span><span class="p">,</span>
            <span class="s2">&quot;eq&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">eq</span><span class="p">,</span>
            <span class="s2">&quot;eq_usd&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">eq_usd</span><span class="p">,</span>
            <span class="s2">&quot;frozen_bal&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">frozen_bal</span><span class="p">,</span>
            <span class="s2">&quot;interest&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">interest</span><span class="p">,</span>
            <span class="s2">&quot;iso_eq&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">iso_eq</span><span class="p">,</span>
            <span class="s2">&quot;liability&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">liability</span><span class="p">,</span>
            <span class="s2">&quot;max_loan&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_loan</span><span class="p">,</span>
            <span class="s2">&quot;notional_lever&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">notional_lever</span><span class="p">,</span>
            <span class="s2">&quot;ord_frozen&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">ord_frozen</span><span class="p">,</span>
            <span class="s2">&quot;upl&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">upl</span><span class="p">,</span>
            <span class="s2">&quot;upl_liability&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">upl_liability</span><span class="p">,</span>
            <span class="s2">&quot;cross_liability&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">cross_liability</span><span class="p">,</span>
            <span class="s2">&quot;iso_liability&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">iso_liability</span><span class="p">,</span>
            <span class="s2">&quot;coin_usd_price&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">coin_usd_price</span><span class="p">,</span>
            <span class="s2">&quot;strategy_eq&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">strategy_eq</span><span class="p">,</span>
            <span class="s2">&quot;spot_in_usd_amt&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">spot_in_usd_amt</span><span class="p">,</span>
            <span class="s2">&quot;iso_upl&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">iso_upl</span>
        <span class="p">}</span></div>
</div>



<span class="c1"># @dataclass</span>
<div class="viewcode-block" id="Account">
<a class="viewcode-back" href="../../../../../pyokx.okx_market_maker.position_management_service.model.Account.html#pyokx.okx_market_maker.position_management_service.model.Account.Account">[docs]</a>
<span class="k">class</span> <span class="nc">Account</span><span class="p">(</span><span class="n">BaseModel</span><span class="p">):</span>
    <span class="n">u_time</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">total_eq</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">iso_eq</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">adj_eq</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">ord_frozen</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">imr</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">mmr</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">notional_usd</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">mgn_ratio</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">details</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">AccountDetail</span><span class="p">]</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="k">lambda</span><span class="p">:</span> <span class="nb">list</span><span class="p">())</span>

<div class="viewcode-block" id="Account.init_from_ws_json_message">
<a class="viewcode-back" href="../../../../../pyokx.okx_market_maker.position_management_service.model.Account.html#pyokx.okx_market_maker.position_management_service.model.Account.Account.init_from_ws_json_message">[docs]</a>
    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">init_from_ws_json_message</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">json_response</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param json_response:</span>
<span class="sd">         {</span>
<span class="sd">          &quot;arg&quot;: {</span>
<span class="sd">            &quot;channel&quot;: &quot;account&quot;,</span>
<span class="sd">            &quot;uid&quot;: &quot;77982378738415879&quot;</span>
<span class="sd">          },</span>
<span class="sd">          &quot;data&quot;: [</span>
<span class="sd">            {</span>
<span class="sd">              &quot;uTime&quot;: &quot;1614846244194&quot;,</span>
<span class="sd">              &quot;totalEq&quot;: &quot;91884.8502560037982063&quot;,</span>
<span class="sd">              &quot;adjEq&quot;: &quot;91884.8502560037982063&quot;,</span>
<span class="sd">              &quot;isoEq&quot;: &quot;0&quot;,</span>
<span class="sd">              &quot;ordFroz&quot;: &quot;0&quot;,</span>
<span class="sd">              &quot;imr&quot;: &quot;0&quot;,</span>
<span class="sd">              &quot;mmr&quot;: &quot;0&quot;,</span>
<span class="sd">              &quot;notionalUsd&quot;: &quot;&quot;,</span>
<span class="sd">              &quot;mgnRatio&quot;: &quot;100000&quot;,</span>
<span class="sd">              &quot;details&quot;: [{</span>
<span class="sd">                  &quot;availBal&quot;: &quot;&quot;,</span>
<span class="sd">                  &quot;availEq&quot;: &quot;1&quot;,</span>
<span class="sd">                  &quot;ccy&quot;: &quot;BTC&quot;,</span>
<span class="sd">                  &quot;cashBal&quot;: &quot;1&quot;,</span>
<span class="sd">                  &quot;uTime&quot;: &quot;1617279471503&quot;,</span>
<span class="sd">                  &quot;disEq&quot;: &quot;50559.01&quot;,</span>
<span class="sd">                  &quot;eq&quot;: &quot;1&quot;,</span>
<span class="sd">                  &quot;eqUsd&quot;: &quot;45078.3790756226851775&quot;,</span>
<span class="sd">                  &quot;frozenBal&quot;: &quot;0&quot;,</span>
<span class="sd">                  &quot;interest&quot;: &quot;0&quot;,</span>
<span class="sd">                  &quot;isoEq&quot;: &quot;0&quot;,</span>
<span class="sd">                  &quot;liab&quot;: &quot;0&quot;,</span>
<span class="sd">                  &quot;maxLoan&quot;: &quot;&quot;,</span>
<span class="sd">                  &quot;mgnRatio&quot;: &quot;&quot;,</span>
<span class="sd">                  &quot;notionalLever&quot;: &quot;0.0022195262185864&quot;,</span>
<span class="sd">                  &quot;ordFrozen&quot;: &quot;0&quot;,</span>
<span class="sd">                  &quot;upl&quot;: &quot;0&quot;,</span>
<span class="sd">                  &quot;uplLiab&quot;: &quot;0&quot;,</span>
<span class="sd">                  &quot;crossLiab&quot;: &quot;0&quot;,</span>
<span class="sd">                  &quot;isoLiab&quot;: &quot;0&quot;,</span>
<span class="sd">                  &quot;coinUsdPrice&quot;: &quot;60000&quot;,</span>
<span class="sd">                  &quot;stgyEq&quot;:&quot;0&quot;,</span>
<span class="sd">                  &quot;spotInUseAmt&quot;:&quot;&quot;,</span>
<span class="sd">                  &quot;isoUpl&quot;:&quot;&quot;</span>
<span class="sd">                }</span>
<span class="sd">              ]</span>
<span class="sd">            }</span>
<span class="sd">          ]</span>
<span class="sd">        }</span>
<span class="sd">        :return:</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">data</span> <span class="o">=</span> <span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;data&quot;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">account</span> <span class="o">=</span> <span class="n">Account</span><span class="p">()</span>
        <span class="n">account</span><span class="o">.</span><span class="n">u_time</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;uTime&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;uTime&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account</span><span class="o">.</span><span class="n">total_eq</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;totalEq&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;totalEq&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account</span><span class="o">.</span><span class="n">iso_eq</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;isoEq&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;isoEq&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account</span><span class="o">.</span><span class="n">adj_eq</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;adjEq&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;adjEq&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account</span><span class="o">.</span><span class="n">ord_frozen</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;ordFroz&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;ordFroz&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account</span><span class="o">.</span><span class="n">imr</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;imr&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;imr&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account</span><span class="o">.</span><span class="n">mmr</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;mmr&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;mmr&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account</span><span class="o">.</span><span class="n">notional_usd</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;notionalUsd&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;notionalUsd&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account</span><span class="o">.</span><span class="n">mgn_ratio</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;mgnRatio&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;mgnRatio&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="n">account</span><span class="o">.</span><span class="n">details</span> <span class="o">=</span> <span class="p">{</span><span class="n">detail_data</span><span class="p">[</span><span class="s2">&quot;ccy&quot;</span><span class="p">]:</span> <span class="n">AccountDetail</span><span class="o">.</span><span class="n">init_from_ws_json_message</span><span class="p">(</span><span class="n">detail_data</span><span class="p">)</span>
                           <span class="k">for</span> <span class="n">detail_data</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s2">&quot;details&quot;</span><span class="p">]}</span>
        <span class="k">return</span> <span class="n">account</span></div>


<div class="viewcode-block" id="Account.update_from_ws_json_message">
<a class="viewcode-back" href="../../../../../pyokx.okx_market_maker.position_management_service.model.Account.html#pyokx.okx_market_maker.position_management_service.model.Account.Account.update_from_ws_json_message">[docs]</a>
    <span class="k">def</span> <span class="nf">update_from_ws_json_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">json_response</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Data pushed in regular interval: Only currencies with non-zero balance will be pushed.</span>
<span class="sd">        Definition of non-zero balance: any value of eq, availEq, availBql parameters is not 0.</span>
<span class="sd">        When the value of eq, availEq and availBql parameters are all zero, drop the detail of that ccy from Account</span>
<span class="sd">        :param json_response: same as init_from_ws_json_message</span>
<span class="sd">        :return:</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">data</span> <span class="o">=</span> <span class="n">json_response</span><span class="p">[</span><span class="s2">&quot;data&quot;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">u_time</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;uTime&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;uTime&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">total_eq</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;totalEq&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;totalEq&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">iso_eq</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;isoEq&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;isoEq&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">adj_eq</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;adjEq&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;adjEq&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ord_frozen</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;ordFroz&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;ordFroz&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">imr</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;imr&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;imr&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mmr</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;mmr&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;mmr&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">notional_usd</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;notionalUsd&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;notionalUsd&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mgn_ratio</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;mgnRatio&quot;</span><span class="p">])</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;mgnRatio&quot;</span><span class="p">)</span> <span class="k">else</span> <span class="mi">0</span>
        <span class="k">for</span> <span class="n">detail_data</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s2">&quot;details&quot;</span><span class="p">]:</span>
            <span class="n">account_detail</span> <span class="o">=</span> <span class="n">AccountDetail</span><span class="o">.</span><span class="n">init_from_ws_json_message</span><span class="p">(</span><span class="n">detail_data</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">account_detail</span><span class="o">.</span><span class="n">eq</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">account_detail</span><span class="o">.</span><span class="n">avail_eq</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">account_detail</span><span class="o">.</span><span class="n">avail_bal</span> <span class="ow">and</span> \
                    <span class="n">account_detail</span><span class="o">.</span><span class="n">ccy</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">details</span><span class="p">:</span>
                <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">details</span><span class="p">[</span><span class="n">account_detail</span><span class="o">.</span><span class="n">ccy</span><span class="p">]</span>
                <span class="k">continue</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">details</span><span class="p">[</span><span class="n">account_detail</span><span class="o">.</span><span class="n">ccy</span><span class="p">]</span> <span class="o">=</span> <span class="n">account_detail</span></div>


<div class="viewcode-block" id="Account.get_account_details">
<a class="viewcode-back" href="../../../../../pyokx.okx_market_maker.position_management_service.model.Account.html#pyokx.okx_market_maker.position_management_service.model.Account.Account.get_account_details">[docs]</a>
    <span class="k">def</span> <span class="nf">get_account_details</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">AccountDetail</span><span class="p">]:</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">details</span></div>


<div class="viewcode-block" id="Account.to_dict">
<a class="viewcode-back" href="../../../../../pyokx.okx_market_maker.position_management_service.model.Account.html#pyokx.okx_market_maker.position_management_service.model.Account.Account.to_dict">[docs]</a>
    <span class="k">def</span> <span class="nf">to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="p">{</span>
            <span class="s2">&quot;u_time&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">u_time</span><span class="p">,</span>
            <span class="s2">&quot;total_eq&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">total_eq</span><span class="p">,</span>
            <span class="s2">&quot;iso_eq&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">iso_eq</span><span class="p">,</span>
            <span class="s2">&quot;adj_eq&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">adj_eq</span><span class="p">,</span>
            <span class="s2">&quot;ord_frozen&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">ord_frozen</span><span class="p">,</span>
            <span class="s2">&quot;imr&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">imr</span><span class="p">,</span>
            <span class="s2">&quot;mmr&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">mmr</span><span class="p">,</span>
            <span class="s2">&quot;notional_usd&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">notional_usd</span><span class="p">,</span>
            <span class="s2">&quot;mgn_ratio&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">mgn_ratio</span><span class="p">,</span>
            <span class="s2">&quot;details&quot;</span><span class="p">:</span> <span class="p">{</span><span class="n">ccy</span><span class="p">:</span> <span class="n">detail</span><span class="o">.</span><span class="n">to_dict</span><span class="p">()</span> <span class="k">for</span> <span class="n">ccy</span><span class="p">,</span> <span class="n">detail</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">details</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span>
        <span class="p">}</span></div>


<div class="viewcode-block" id="Account.from_dict">
<a class="viewcode-back" href="../../../../../pyokx.okx_market_maker.position_management_service.model.Account.html#pyokx.okx_market_maker.position_management_service.model.Account.Account.from_dict">[docs]</a>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">account_dict</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">u_time</span> <span class="o">=</span> <span class="n">account_dict</span><span class="p">[</span><span class="s2">&quot;u_time&quot;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">total_eq</span> <span class="o">=</span> <span class="n">account_dict</span><span class="p">[</span><span class="s2">&quot;total_eq&quot;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">iso_eq</span> <span class="o">=</span> <span class="n">account_dict</span><span class="p">[</span><span class="s2">&quot;iso_eq&quot;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">adj_eq</span> <span class="o">=</span> <span class="n">account_dict</span><span class="p">[</span><span class="s2">&quot;adj_eq&quot;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ord_frozen</span> <span class="o">=</span> <span class="n">account_dict</span><span class="p">[</span><span class="s2">&quot;ord_frozen&quot;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">imr</span> <span class="o">=</span> <span class="n">account_dict</span><span class="p">[</span><span class="s2">&quot;imr&quot;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mmr</span> <span class="o">=</span> <span class="n">account_dict</span><span class="p">[</span><span class="s2">&quot;mmr&quot;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">notional_usd</span> <span class="o">=</span> <span class="n">account_dict</span><span class="p">[</span><span class="s2">&quot;notional_usd&quot;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mgn_ratio</span> <span class="o">=</span> <span class="n">account_dict</span><span class="p">[</span><span class="s2">&quot;mgn_ratio&quot;</span><span class="p">]</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">details</span> <span class="o">=</span> <span class="p">{</span><span class="n">ccy</span><span class="p">:</span> <span class="n">AccountDetail</span><span class="p">(</span><span class="o">**</span><span class="n">detail</span><span class="p">)</span> <span class="k">for</span> <span class="n">ccy</span><span class="p">,</span> <span class="n">detail</span> <span class="ow">in</span> <span class="n">account_dict</span><span class="p">[</span><span class="s2">&quot;details&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span>

        <span class="k">return</span> <span class="bp">self</span></div>
</div>


</pre></div>

           </div>
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2024, Ruben Fernandez Carbon.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>